/**
 * 
 */
package profile.result;

import java.util.HashMap;
import java.util.Map;

/**
 * @author ductrung.tran
 *
 */
public class ContextResult {

	private String name;
	
	private Map<String, StoreResult> storeResultMap = new HashMap<String, StoreResult>();

	public ContextResult(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}
	
	public Map<String, StoreResult> getStoreResultMap() {
		return storeResultMap;
	}

	public void addStoreResult(StoreResult storeResult) {
		StoreResult existResult = getStoreResult(storeResult.getStore());
		if (existResult != null) {
			existResult.merge(storeResult);
		} else {
			storeResultMap.put(storeResult.getStore(), storeResult);
		}
	}

	public StoreResult getStoreResult(String store) {
		return storeResultMap.get(store);
	}

	public void merge(ContextResult contextResult) {
		for (StoreResult testResult : contextResult.getStoreResultMap().values()) {
			addStoreResult(testResult);
		}
	}
}
